package com.iengoo.inductionms.service.impl;

import com.iengoo.inductionms.common.AccountExcel;
import com.iengoo.inductionms.common.EduExcel;
import com.iengoo.inductionms.common.PayExcel;
import com.iengoo.inductionms.common.StaffInfoExcel;
import com.iengoo.inductionms.config.ExcelConfig;
import com.iengoo.inductionms.service.EmployeeService;
import com.iengoo.inductionms.service.ExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author zpym
 * @CopyRight (C) http://www.iengoo.com
 * @brief
 * @email 122162005@qq.com
 * @date 2019-03-10 22:22
 */
@Service
public class ExportServiceImpl implements ExportService {
    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private ExcelConfig excelConfig;

    @Override
    public void accountExport(String name) {
        try {
            // TODO
            AccountExcel.export(excelConfig.getExcelPath(), name + ".xls", null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void eduExport(String name) {
        try {
            EduExcel.export(excelConfig.getExcelPath(), name, employeeService.query(null));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void payExport(String name) {
        try {
            // TODO
            PayExcel.export(excelConfig.getExcelPath(), name, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void entry(String name) {
        try {
            // TODO
            StaffInfoExcel.export(excelConfig.getExcelPath(), name, null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
